package dfcd.com.maintest

import android.annotation.SuppressLint
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import kotlinx.android.synthetic.main.layout_a.*
import kotlinx.android.synthetic.main.layout_a.view.*

class FragmentA : Fragment() {

    private var mView: View? = null

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        if (mView == null) {
            mView = inflater.inflate(R.layout.layout_a, container, false)
        }
        val params = mView?.parent as? ViewGroup
        params?.removeAllViews()
        initView()

        return mView


    }

    @SuppressLint("SetTextI18n")
    private fun initView() {
        mView?.tv_text1?.text = "hello kotlin"
        mView?.tv_text2?.text = "hello java"

        tv_text2.text = "hello java"

        tv_text1.setOnClickListener {
            Toast.makeText(activity, "haha", Toast.LENGTH_SHORT).show()
        }

    }

}
